package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.service.IUserPurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户购买记录表 前端控制器
 * </p>
 *
 * @author gax
 * @since 2025-09-25
 */
@RestController
@RequestMapping("userPurchase")
public class UserPurchaseController {

    @Autowired
    private IUserPurchaseService userPurchaseService;

    /** 购买：写入 user_purchase（幂等） */
    @GetMapping("buy/{id}")
    public Result<String> buy(@PathVariable Long id, @RequestParam Long userId) {
        userPurchaseService.buy(id, userId);
        return Result.ok();
    }
}
